package com.hh.utils;

import com.hh.commen.bean.CurrencyEnum;
import com.hh.commen.bean.PriceTypeEnum;
import com.hh.commen.bean.StatusEnum;

import java.util.Calendar;
import java.util.Date;

/**
 * @author Hanh
 * @date 2023/8/9 13:01s
 */

public class SparePriceUtil {

    private static Calendar calendar = Calendar.getInstance();


    //做一个根据获取到的status返回对应的statusName  0禁用 1启用
    public static String getStatusName(Integer status){
        if (status==StatusEnum.JINYONG.getValue()){
            return StatusEnum.JINYONG.getName();
        }else {
            return StatusEnum.QIYONG.getName();
        }
    }

    //根据货币类型id获取到对应的名称
    public static String getCurrencyCodeName(Integer currencyCode){
        for (CurrencyEnum currency : CurrencyEnum.values()){
            if (currency.getValue()==currencyCode){
                return currency.getName();
            }
        }
        return "货币类型错误,查无此货币";
    }

    //根据价格分类id获取对应的名称
    public static String getPriceTypeName(Integer priceType){
        for (PriceTypeEnum priceTypeEnum:PriceTypeEnum.values()){
            if (priceTypeEnum.getValue()==priceType){
                return priceTypeEnum.getName();
            }
        }
        return "价格分类错误，查无此分类";
    }

    //获取指定日期的前一天  把0改为-1即可
    public static Date getPreviousDay(Date date){
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_YEAR,0);
        return calendar.getTime();
    }
    //获取指定日期的后一天 把0改为1即可
    public static Date getNextDay(Date date){
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_YEAR,0);
        System.out.println();
        return calendar.getTime();
    }

}
